{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3fb43f56-9dc7-4edd-be43-469b67e2533c",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "'paddlex' 不是内部或外部命令，也不是可运行的程序\n",
      "或批处理文件。\n"
     ]
    }
   ],
   "source": [
    "!paddlex --export_interence--model_dir=./data/best_model --save_dir=./inference_model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5f6d1d14-06c9-4f55-8ba9-5bd62fde4fc0",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "'unzip' 不是内部或外部命令，也不是可运行的程序\n",
      "或批处理文件。\n"
     ]
    }
   ],
   "source": [
    "!unzip -oq best_model.zip"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ec51c690-148a-49c1-a19b-bd9f9a59929d",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "'paddlex' 不是内部或外部命令，也不是可运行的程序\n",
      "或批处理文件。\n"
     ]
    }
   ],
   "source": [
    "!paddlex --export_inference --model_dir=./data/best_model --save_dir=./inference_model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5d2ecc94-0665-452b-9bbe-c459d732067b",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'paddlex'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[7], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m#导入库\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpaddlex\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpdx\u001b[39;00m\n\u001b[0;32m      3\u001b[0m \u001b[38;5;66;03m#加载模型进行预测\u001b[39;00m\n\u001b[0;32m      4\u001b[0m predictor\u001b[38;5;241m=\u001b[39mpdx\u001b[38;5;241m.\u001b[39mdeploy\u001b[38;5;241m.\u001b[39mPredictor(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m./inference_model\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'paddlex'"
     ]
    }
   ],
   "source": [
    "#导入库\n",
    "import paddlex as pdx\n",
    "#加载模型进行预测\n",
    "predictor=pdx.deploy.Predictor('./inference_model')\n",
    "#模型预测结果\n",
    "result=predictor.predict('data/garbage/paper/paper1.jpg')\n",
    "#输出结果\n",
    "print(result)\n",
    "#提取分类\n",
    "category=result[0]['category']\n",
    "#输出分类结果\n",
    "category"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a2ed3fa2-0200-4a01-b7d9-c686855fa417",
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入库\n",
    "import paddlex as pdx\n",
    "#加载模型进行预测\n",
    "predictor=pdx.deploy.Prodictor('./inference_model')\n",
    "#生成批量图片列表\n",
    "image_list=['data/garbage/paper/paper10.jpg','data/garbage/plastic/plastic10.jpg','data/garbage/glass/glass10.jpg']\n",
    "#模型预测结果\n",
    "result=predictor.batch_predict(image_list=image_list)\n",
    "#输出结果\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c03ae5e5-bcfd-4c94-af51-14827672e812",
   "metadata": {},
   "outputs": [],
   "source": [
    "WITH_GPU=OFF\n",
    "WITH_MKL=OFF\n",
    "WITH_TENSORRT=OFF\n",
    "TENSORRT_DIR=/home/dlinano/projects/TensorRT/\n",
    "PADDLE_DIR=/home/dlinano/projects/fluid_inference\n",
    "WITH_STATIC_LIB=OFF\n",
    "CUDA_LIB=/usr/local/cuda/lib64\n",
    "CUDNN_LIB=/usr/local/cuda/lib64\n",
    "\n",
    "rm -rg build\n",
    "mkdir -p build\n",
    "cd build\n",
    "cmake..\\\n",
    "    -DWITH_GPU=${WITH_GPU}\\\n",
    "    -DWITH_MKL=${WITH_MKL}\\\n",
    "    -DWITH_TENSORRT=${WITH_TENSORRT}\\\n",
    "    -DWITH_ENCRYPTION=${WITH_ENCRYPTION}\\\n",
    "    -DTENSORRT_DIR=${TENSORRT_DIR}\\\n",
    "    -DPADDLE_DIR=${PADDLLE_DIR}\\\n",
    "    -DWITH_STATIC_LIB=${WITH_STATIC_LIB}\\\n",
    "    -DCUDA_LIB=${CUDA_LIB}\\\n",
    "    -DCUDNN_LIB=${CUDNN_LIB}\n",
    "make"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "cdee2533-9885-47b4-823c-407a8ebed4e7",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (3214037949.py, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn[11], line 2\u001b[1;36m\u001b[0m\n\u001b[1;33m    sh ./scripts/jetson_build.sh\u001b[0m\n\u001b[1;37m        ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "cd /home/dlinano/projects/PaddleX/deploy/cpp\n",
    "sh ./scripts/jetson_build.sh"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0ab68d84-96c2-496c-b1cb-46a72c1e9b16",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (3296866027.py, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn[13], line 2\u001b[1;36m\u001b[0m\n\u001b[1;33m    |\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "PaddleX\n",
    "|\n",
    "inference_model\n",
    "|\n",
    "fluid_inference\n",
    "| paddle\n",
    "|\n",
    "  |third_party\n",
    "|\n",
    "  |version.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "8e0be361-0479-4cda-a000-e02350c9a0e5",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "expression cannot contain assignment, perhaps you meant \"==\"? (2213141459.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn[15], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m    home/dlinano/projects/PaddleX/deploy/cpp/build/demo/classifier(--model_dir=/home/)\u001b[0m\n\u001b[1;37m                                                                   ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m expression cannot contain assignment, perhaps you meant \"==\"?\n"
     ]
    }
   ],
   "source": [
    "/home/dlinano/projects/PaddleX/deploy/cpp/build/demo/classifier --model_dir=/home/\n",
    "dlinano/projects/inference_model --image=/home/dlinano/projects/images/test.jpg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "03055c07-2e94-45bf-ac71-9b441243d80e",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "expression cannot contain assignment, perhaps you meant \"==\"? (66699794.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn[17], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m    home/dlinano/projects/PaddleX/deploy/cpp/build/demo/video_classifier(--model_dir=/)\u001b[0m\n\u001b[1;37m                                                                         ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m expression cannot contain assignment, perhaps you meant \"==\"?\n"
     ]
    }
   ],
   "source": [
    "/home/dlinano/projects/PaddleX/deploy/cpp/build/demo/video_classifier --model_dir=/\n",
    "home/dlinano/projects/inference_model --use_camera=1 --use_gpu=1 --save_dir=/home/\n",
    "dlinano/projects/output --save_result=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "471dcc00-0d8e-4dd9-a364-fd508c9208b0",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "expression cannot contain assignment, perhaps you meant \"==\"? (1714207110.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn[19], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m    home/dlinano/projects/PaddleX/deploy/cpp/build/demo/video_classifier(--model_dir=/)\u001b[0m\n\u001b[1;37m                                                                         ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m expression cannot contain assignment, perhaps you meant \"==\"?\n"
     ]
    }
   ],
   "source": [
    "/home/dlinano/projects/PaddleX/deploy/cpp/build/demo/video_classifier --model_dir=/\n",
    "home/dlinano/projects/inference_model --video_path=/home/dlinano/projects/images/test.\n",
    "mp4 --use_gpu=1 --save_dir=output --show_result=1 --save_result=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3e3002f2-dc19-4ac7-a119-d5994b02446c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
